<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body>
		<p id="arrold"></p>
		<p>
			<input type="button" onclick="asc()"value="升序"/>
			<input type="button" onclick="desc()" value="降序"/>
		</p>
		<p id="arrnew"></p>
		<script type="text/javascript">
var arr=[5,3,40,1,67];
var old=document.getElementById('arrold');
old.innerText=arr;
var mynew =document.getElementById('arrnew');
function asc(){
mynew.innerText=arr.sort(function(a,b){return a-b});
}
function desc(){
mynew.innerText=arr.sort(function(a,b){return b-a});
}
		</script>
	</body>
</html>
